package com.ruoyi.system.service.carte.job.impl;

import cn.hutool.json.JSONUtil;
import com.ruoyi.system.domain.request.JobExecuteRequest;
import com.ruoyi.system.domain.request.JobRunRequest;
import com.ruoyi.system.service.carte.job.IJobExecute;
import com.ruoyi.system.service.carte.job.IJobRun;
import com.ruoyi.system.service.carte.job.IJobTask;
import com.ruoyi.system.service.carte.trans.ITransTask;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class JobTaskImpl implements IJobTask {

    @Autowired
    private IJobExecute jobExecuteImpl;

    @Autowired
    private IJobRun jobRunImpl;

    //没掉通
    @Override
    public String run(String jsonStr) throws Exception{
        JobRunRequest transRequest  =JSONUtil.toBean(jsonStr,JobRunRequest.class);
        return jobRunImpl.runJob(transRequest);
    }

    //正常work
    @Override
    public String exec(String jsonStr) throws Exception {
        JobExecuteRequest transRequest  =JSONUtil.toBean(jsonStr,JobExecuteRequest.class);
        return jobExecuteImpl.executeJob(transRequest);
    }
}
